/**
 * 地图的功能
 * author：suyuyi
 * Date ： 2017-3-30
 */
cc.Class({
    extends: cc.Component,
    
    properties: {
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
        _mapWidth:2000,
        _mapHeight:1000,
        _mapSize:50
    },

    // use this for initialization
    onLoad: function () {
        this.touchValid = true;
        this.touchAreaRedius = 300;
        
        this.ctx = this.node.getComponent(cc.Graphics);
        this.hero = cc.find("Canvas/hero",this.node);
        this.accelerate = cc.find("Canvas/accelerate",this.node);
        this.attack = cc.find("Canvas/attack",this.node);
        //this.node.getComponent(cc.Button).transition = cc.Button.Transition.NONE;
        if(this.ctx){
            this.ctx.rect(0,0,2000,1000);
            this.ctx.fillColor = cc.color(38,36,53,255);
            this.ctx.fill();
            this.ctx.rect(0,0,250,1000);
             this.ctx.fillColor = cc.color(100,0,0,255);
             this.ctx.fill();
             this.ctx.rect(1750,0,250,1000);
             this.ctx.fillColor = cc.color(100,0,0,255);
             this.ctx.fill();
            for(var i = 0; i <= this._mapWidth; i += this._mapSize){
                 this.ctx.moveTo(i, 0);
                 this.ctx.lineTo(i, this._mapHeight);
                 this.ctx.strokeColor = cc.color(255,255,255,100);
                 this.ctx.stroke();
            }
            for(var j = 0; j <= this._mapHeight; j += this._mapSize)
            {
                if (j == 150 || j == 1000 - 150 ){
                    cc.log(j);
                    this.ctx.strokeColor = cc.color(255,255,255,50);
                    this.ctx.lineWidth   = 7;
                    cc.log(this.ctx.lineWidth);
                }
                else {
                    this.ctx.strokeColor = cc.color(255,255,255,100);
                    this.ctx.lineWidth   = 1;
                }
                 this.ctx.moveTo(0, j);
                 this.ctx.lineTo(this._mapWidth, j);
                 this.ctx.stroke();
            }
            
             
            


        }
        else{
            cc.log("null");
        }

        this.node.on(cc.Node.EventType.MOUSE_MOVE, this.bgMove, this);
        
    },
    bgMove: function(event){
        var pos = this.node.convertTouchToNodeSpace(event);

    },
    
    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
